﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FormPage.aspx.cs" Inherits="Easy.Web.Pages.DataPages.Form.FormPage" %>

<!DOCTYPE html>
<html lang="zh-cn">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>蓝灵儿</title>
    <script src="/_js/MobilePcFormBirdge.js"></script>
    <link href="/_css/bootstrap.min.css" rel="stylesheet" />
    <link href="/_css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="/_css/sort.css" rel="stylesheet" type="text/css" />
    <link href="/_css/common.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/_css/iconfont.css" />
    <link href="/_css/imgViewer/viewer.min.css" rel="stylesheet" />
    <style>
        body {
            margin: 0 auto;
            height: 100%;
            background: #00AEEF;
        }

        html, body, input, ul, li, div, span, label {
            font-size: 9pt;
            border: 0;
            margin: 0;
            padding: 0;
        }

        .form-group {
            margin-bottom: 10px;
        }

        .header {
            padding: 10px 0 10px 15px;
            margin:0;
            position:fixed;
            z-index:100;
            background:white;
            left:200px;
            border-bottom:1px dotted #cccccc;
        }

        #Top {
            background-color: #09C;
            font-size: 14px;
            font-family: 'Microsoft YaHei';
            display: none;
            height: 50px;
            color: #FFF;
        }

            #Top a {
                text-decoration: none;
                color: #fff;
                text-align: center;
                line-height: 50px;
                display: inline-block;
            }

                #Top a:hover, #Top a:active, #Top a:visited, #Top a:focus {
                    text-decoration: none;
                    background-color: #008fbf;
                    color: #fff;
                }

        #Left {
            float: left;
            width: 187px;
            display: none;
            background-color: black;
        }

        #Content {
            margin-left: 187px;
            display: none;
            overflow-y: auto;
            overflow-x: hidden;
            background-color: white;
        }

        .EntityLinkContent {
            display: none;
            text-align: center;
        }

        #BackGroundMessage {
            /*background-color:black;*/
        }


        ul {
            display: block;
            margin: 0;
            padding: 0;
            list-style: none;
        }

        li {
            display: block;
            margin: 0;
            padding: 0;
            list-style: none;
        }

        img {
            border: 0;
        }

        dl, dt, dd > span {
            margin: 0;
            padding: 0;
            display: block;
        }

        .EntityLinkContainer, .FormContainer {
            width: 100%;
            height: 100%;
        }

        #Left a, a:focus {
            text-decoration: none;
            color: #FFFFFF;
            outline: none;
            blr: expression(this.onFocus=this.blur());
        }

        #LookupListContainer a:hover {
            color: #337ab7;
            text-decoration: none;
        }
        #LookupListContainer a:focus {
            color: #337ab7;
            text-decoration: none;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0;
        }

        cite {
            font-style: normal;
        }

        h2 {
            font-weight: normal;
        }

        .topbar-left a {
            float: left;
            height: 50px;
        }

        .topbar-right {
            float: right;
        }

            .topbar-right a {
                padding: 0 10px;
            }

        .leftmenu {
            width: 187px;
            overflow: hidden;
            height: 100%;
        }

            .leftmenu dd {
                background: #22282e;
                line-height: 35px;
                color: #FFFFFF;
                font-weight: bold;
                font-size: 14px;
                border-right: solid 1px #414D5C;
                border-bottom: solid 1px #414D5C;
            }

                .leftmenu dd span {
                    float: left;
                    margin: 10px 8px 0 12px;
                    height: 16px;
                    width: 16px;
                }

                .leftmenu dd a {
                    display: block;
                }

                    .leftmenu dd a:hover {
                        background: #414D5C;
                    }

                .leftmenu dd .menuson {
                    height: 0;
                    overflow: hidden;
                }

        .menuson {
            line-height: 30px;
            font-weight: normal;
            background: #293038;
        }

            .menuson li {
                cursor: pointer;
            }

                .menuson li:hover {
                    background: #37424F;
                }

                .menuson li.active {
                    position: relative;
                    background: #0099CC;
                    line-height: 30px;
                    color: #fff;
                }

                .menuson li span {
                    display: block;
                    float: left;
                    margin-left: 32px;
                    width: 17px;
                    height: 17px;
                    margin-top: 7px;
                }

                .menuson li a {
                    display: block;
                    *display: inline;
                    *padding-top: 5px;
                }

                .menuson li.active a {
                    color: #fff;
                }

        #LookupListContainer {
            height: 420px;
            width: 558px;
            overflow: auto;
            margin-top: 8px;
            border: 1px solid #e1e6eb;
        }

        #LookupListContainer-title {
            position: relative;
            z-index: 1;
        }

        #LookupListContainer-body {
            position: relative;
        }

            #LookupListContainer-title .table, #LookupListContainer-body .table {
                margin: 0;
                border: none;
            }

        .control-label {
            margin-right: 0px;
            vertical-align: middle;
            display: inline-block;
            height: 32px;
            line-height: 32px;
            white-space: nowrap;
            -moz-text-overflow: ellipsis;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        label {
            padding-right: 0 !important;
        }
        .arrow1 {
          width: 20px;
          height: 20px;
          top:5px;
          position: relative;
          display: inline-block;
        }
        .arrow1:before, .arrow1:after {
          content: '';
          border-color: transparent;
          border-style: solid;
          position: absolute;
        }

        .arrow1-right:before {
          border: none;
          background-color: #000;
          height: 30%;
          width: 50%;
          top: 35%;
          left: 0;
        }
        .arrow1-right:after {
          left: 50%;
          top: 0;
          border-width: 10px 10px;
          border-left-color: #000;
        }
        .order-stamp {
	      position: absolute;
	      width: 120px;
	      height: 35px;
	      border: 2px solid #fff;
	      line-height: 30px;
	      text-align: center;
	      font-size: 18px;
	      font-weight: 900;
	      font-family: 'SimSun';
	      -moz-transform: rotate(-10deg);
	      -ms-transform: rotate(-10deg);
	      -o-transform: rotate(-10deg);
	      -webkit-transform: rotate(-10deg);
	      transform: rotate(-10deg);
	      padding: 1px 5px;
	      top: 65px;
	      z-index: 9999;
	      overflow: hidden;
	    }
	    .order-stamp.stamp-success {
	      color: #f00;
	      border-color: #f00;
	    }
	    .order-stamp.stamp-cancel {
	      color: #8d8888;
	      border-color: #8d8888;
	    
    </style>

    <script src="/_js/CodeMirror/codemirror.js"></script>
    <link href="/_css/codemirror.css" type="text/css" rel="stylesheet" />
    <script src="/_js/CodeMirror/CodeMirrorAddon/selection/selection-pointer.js"></script>
    <script src="/_js/CodeMirror/CodeMirrorAddon/selection/active-line.js"></script>
    <script src="/_js/CodeMirror/CodeMirrorAddon/edit/matchbrackets.js"></script>
    <script src="/_js/CodeMirror/CodeMirrorAddon/edit/matchtags.js"></script>



    <asp:Literal runat="server" ID="CoreScript"></asp:Literal>
</head>
<body>
    <div id="BackGroundMessage">
        <img style="margin: auto; display: block" src="/_imgs/formloading.gif" alt="aaa" />
    </div>
    <div id="Top">
        <div class="aliyun-console-topbar" data-spm="101" data-spm-max-idx="63">
            <div class="topbar-wrap topbar-clearfix">
                <div class="topbar-head topbar-left">
                    <a href="/default.aspx" target="_self" class="topbar-logo topbar-left" style="background-color: #0087b4; width: 50px;">
                        <span>
                            <img src="/_imgs/logo.gif" style="width: 35px; height: 35px" />
                        </span>
                    </a>
                    <a href="javascript:location.reload()" target="_self" class="topbar-home-link topbar-btn topbar-left" style="padding: 0 20px;">
                        <span style="font-size: 14px; font-family: 'Microsoft YaHei';text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:300px;display:block;" id="CurrentRecord"></span>
                    </a>
                </div>
                <div class="topbar-info topbar-right">
                    <div class="topbar-left">
                        <div class="topbar-info-item">
                            <a href="/Pages/DataPages/Form/FormPage.aspx?entityname=systemuser&id=<%=this.CurrentUserId %>" target="_blank" id="admin" class="topbar-home-link topbar-btn topbar-left" currentuserid="<%=this.CurrentUserId%>" currentusername="<%=this.GetSystemUser().Name %>"><span style="font-size: 14px; font-family: 'Microsoft YaHei'"><%=this.GetSystemUser().Name %></span></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="Left">
        <dl class="leftmenu">
            <dd>
                <div id="contentItem" class="title"><span class="glyphicon glyphicon glyphicon-th-list"></span><a id="basicForm" href="javascript:void(0);">表单信息</a></div>
            </dd>
        </dl>
    </div>
    <div id="Content" style="overflow-y: hidden">
        <div class="_FormContainer" style="overflow-y: auto; overflow-x: hidden">
            <div class="header">
                <%=FormButton %>
                <%--<span><a href="#" class="btn btn-primary ng-binding" title="Save" onclick="SaveData('save')"><span class="glyphicon glyphicon-floppy-save"></span>&nbsp;Save</a>
                </span>--%>
            </div>
            <div id="FormContainer" class="row">
                <%=FormHtml %>
            </div>
            <div id="LookupModal" class="modal fade in" etn="" fieldid="">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">搜索:<span id="modal-title-etn"></span></h4>
                        </div>
                        <div class="modal-body" style="max-height: 500px; overflow: hidden">
                            <div class="input-group">
                                <input type="text" id="txt_lookupsearchValue" onkeypress="if(event.keyCode == 13) core.Lookup.Search();" class="form-control" placeholder="搜索内容..." />
                                <span class="input-group-btn">
                                    <button class="btn btn-primary ng-binding" type="button" onclick="core.Lookup.Search();">搜索</button>
                                </span>
                            </div>
                            <div id="LookupListContainer">
                                <div id="LookupListContainer-title">
                                    <table id="" class="table table-condensed table-hover">
                                        <colgroup></colgroup>
                                        <thead></thead>
                                    </table>
                                </div>
                                <div id="LookupListContainer-body">
                                    <table id="" class="table table-condensed table-hover">
                                        <colgroup></colgroup>
                                        <tbody></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <nav id="ListPageing" style="float: left;">
                                <ul class="pagination" style="margin: 0;">
                                    <li><a href="javascript:void(0);" id="pageFirst" aria-label="Firset" onclick='core.Lookup.FirstPage();'><span aria-hidden="true">&laquo;</span>
                                    </a></li>
                                    <li><a href="javascript:void(0);" id="pagePrevious" aria-label="Previous" onclick='core.Lookup.PrePage();'><span aria-hidden="true">&lsaquo;</span>
                                    </a></li>
                                    <li><span id="pageInfo">1\50</span></li>
                                    <li><a href="javascript:void(0);" id="pageNext" aria-label="Next" onclick='core.Lookup.NextPage();'><span aria-hidden="true">&rsaquo;</span>
                                    </a></li>
                                    <li><a href="javascript:void(0);" id="pageLast" aria-label="Last" onclick='core.Lookup.LastPage();'><span aria-hidden="true">&raquo;</span>
                                    </a></li>
                                </ul>
                            </nav>
                            <button type="button" class="btn btn-primary ng-binding" onclick="core.Lookup.SelectedLookup();"
                                data-dismiss="modal">
                                OK</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <div class="_EntityLinkContainer" style="overflow-y: hidden">
            <iframe id="EntityLinkFrame" style="width: 100%; height: 100%; border: 0px;" name="EntityLinkFrame"></iframe>
        </div>

        <!-- attachment -->
        <div id="shade" class="modal-backdrop fade in" style="display: none; z-index: 2; text-align: center"></div>
        <div id="AddAttachment" align="center" style="position: absolute; width: 400px; height: 360px; overflow: auto; left: 200px; top: 100px; z-index: 9; display: none; background-color: #fff; border: 1px solid #222;">
            <input id="ImportFile" name="ImportFile" type="file" onchange="imgchange()" style="display: none" />
            <input id="att_AttrachmentId_add" type="hidden">
            <input id="att_attflag_add" type="hidden">

            <div style="position: relative; width: 200px; height: 200px; top: 15px;">
                <img style="width: 200px; height: 200px;" src="" id="att_image_add" /><span id="tip" onclick="ImportFile.click()" style="cursor: pointer; opacity: 0.4; position: absolute; bottom: 0; left: 0; width: 200px; height: 200px; background: #000; font-size: 30px; color: #FFF; line-height: 200px;">点击上传</span></div>
            <p>
                <label style="font-size: 12px; margin-top: 30px;">
                    名称：
                    <input id="att_name_add" type="text" style="border: 1px solid #CCC; height: 32px; padding: 6px; font-size: 12px; color: #555;" />
                </label>
            </p>
            <p>
                <label style="font-size: 12px">
                    说明：
                    <input id="att_desc_add" type="text" style="border: 1px solid #CCC; height: 32px; padding: 6px; font-size: 12px; color: #555;" />
                </label>
            </p>
            <div class="btn btn-primary ng-binding" onclick="SaveAttachmentRecord();"><span>保存</span></div>
            <div class="btn btn-primary ng-binding" onclick="Attachment.StyleJS.hidediv();"><span>关闭</span></div>
        </div>
    </div>

    <script src="/_js/json2.js" type="text/javascript"></script>
    <script src="/_js/jquery-1.9.1.min.js"></script>
    <script src="/_js/bootstrap.min.js"></script>
    <script src="/_js/bootstrap-datetimepicker.min.js"></script>
    <script src="/_js/common.js"></script>
    <script src="/_js/Core.js"></script>
    <script src="/_js/Core.Form.js"></script>
    <script src="/_js/Core.Lookup.js"></script>
    <script src="/_js/ajaxfileupload.js"></script>
    <script src="/_js/imgViewer/viewer.min.js"></script>
    <script src="/_js/FormAttachment.js"></script>
    <script type="text/javascript">
        function getQueryString(name)
        {
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
            {
                return unescape(r[2]);
            }
            return null;
        }
        function setLeftTop()
        {
            var top = getQueryString("top");
            var left = getQueryString("left");
            if (!!top && top == 0)
            {
                $("#Top").css('display', 'none');
                $("#Content").css({ 'height': '100%', 'padding-top': '0px' });
                $("#Left").css({ "padding-top": "0px", "position": "fixed", "height": "100%" });
                $("._FormContainer").css('height', '100%');
                $(".header").css({ "width": $("#FormContainer").width() - 42 + "px" });
                $("#FormContainer").css({ "margin-top": $(".header").height() + 30 + "px" });
            }
            if (!!left && left == 0)
            {
                $(".header").css({ "margin-left": "15px" });
                $("#Left").css('display', 'none');
                $("#Content").css({ 'width': '100%', 'margin': '0px' });
                $("._FormContainer").css({ 'width': '100%', 'margin': '0px;' });
                $(".header").css({ "width": $("#FormContainer").width() - 42 + "px", "left": "0" });

                $("#FormContainer").css({ "margin-top": $(".header").height() + 30 + "px", "height": "100%" });
            }
        }
        $(function ()
        {
            /*---------------------------------------页面框架布局 begin---------------------------------------------*/
            (function ()
            {
                $(".header").css("padding-left", "0");
                $(".header").css({ "width": $("#FormContainer").width() - 58 + "px" });
                $("#FormContainer").css({ "margin-top": $(".header").height() + 30 + "px" });
                //$("#Left").height($(window).height() - 50).show();//100是顶部高度
                //$("#Content").height($(window).height() - 50).show();//100是顶部高度
                //$("._FormContainer").height($(window).height() - 50).show();//100是顶部高度
                //$("._EntityLinkContainer").height($(window).height() - 50).show();//100是顶部高度
                //$("#Top").show();
                //$("#BackGroundMessage").hide();

                $(window).resize(function ()
                {
                    $(".header").css({ "width": $("#FormContainer").width() - 42 + "px" });
                    $("#FormContainer").css({ "margin-top": $(".header").height() + 30 + "px" });
                    $("#Left").height($(window).height() - 50);//100是顶部高度
                    $("#Content").height($(window).height() - 50);//100是顶部高度
                    $("._FormContainer").height($(window).height() - 50);//100是顶部高度
                    $("._EntityLinkContainer").height($(window).height() - 50);//100是顶部高度

                    setLeftTop();

                });//当浏览器窗口变化时对各窗口大小进行重置      
            })();
            //top  left参数判断
            (function ()
            {
                setLeftTop();
            })();
            /*---------------------------------------页面框架布局 begin---------------------------------------------*/

            /*---------------------------------------Top部分处理 begin---------------------------------------------*/
            (function ()
            {
                var titleText = "";
                if (XFormData != null)
                {
                    var showname = "";
                    for (var i in EntityField)
                    {
                        if (EntityField[i].IsPrimaryAtt == true)
                        {
                            showname = i;
                        }
                    }

                    titleText = EntityDisplayName + "：" + XFormData[showname];
                }
                else
                {
                    titleText = EntityDisplayName + "：[创建]";
                }
                $("title").text(titleText);
                $("#CurrentRecord").text(titleText);
            })();
            /*---------------------------------------Top部分处理 begin---------------------------------------------*/

            /*---------------------------------------导航切换 begin---------------------------------------------*/
            (function ()
            {
                if (typeof (FormId) != "undefined")
                {
                    function initParam(s)
                    {
                        s = s.replace("{id}", $.getQueryString("id"));
                        s = s.replace("{entitydisplayname}", EntityDisplayName);
                        s = s.replace("{recorddisplayname}", (XFormData["name"] == null ? XFormData[Prefix + "_name"] : XFormData["name"]));
                        return s;
                    }
                    $.ajax({
                        type: "GET",
                        url: "/Service/data/getEntityLinkList.ashx",
                        data: {
                            entityname: EntityName
                        },
                        dataType: "json",
                        success: function (data)
                        {
                            $(data).each(function ()
                            {
                                var temp = "";
                                var item = this;
                                item.src = initParam(item.src);
                                if (item.src != null && item.src != "")
                                {
                                    temp = '<dd>\
                                            <div class="title">\
                                                <span class="glyphicon glyphicon-th-list"></span>\
                                                <a href="' + ((item.src != null && item.src != "") ? item.src : "") + '" target="EntityLinkFrame">' + item.oname + '</a>\
                                            </div>\
                                        </dd>';
                                }
                                else
                                {
                                    temp = '<dd>\
                                            <div class="title">\
                                                <span class="glyphicon glyphicon-th-list"></span>\
                                                <a href="javascript:void(0)" target="EntityLinkFrame">' + item.oname + '</a>\
                                            </div>\
                                            <ul class="menuson">';
                                    $(item.second).each(function ()
                                    {
                                        temp += '<li>\
                                                 <span class="glyphicon glyphicon-chevron-right"></span>\
                                                 <a href="' + ((this.src != null && this.src != "") ? this.src : "") + '" target="EntityLinkFrame">' + this.oname + '</a>\
                                             </li>';
                                    });
                                    temp += '</ul></dd>';
                                }
                                $(".leftmenu").append(temp);


                                //绑定列表相关事件
                                $(".menuson li").on("click", function ()
                                {
                                    $(".menuson li.active").removeClass("active")
                                    $(this).addClass("active");
                                    $("._FormContainer").hide();
                                    $("._EntityLinkContainer").show();
                                })


                                $(".title").on("click", function ()
                                {
                                    if ($(this).next('ul').height() == 0)
                                    {
                                        $(this).next('ul').animate({
                                            'height': $(this).next('ul').find('li').length * 30
                                        }, 300);
                                    } else
                                    {
                                        $(this).next('ul').animate({
                                            'height': 0
                                        }, 300);
                                    }
                                    if ($(this).attr("id") != "contentItem")
                                    {
                                        $("._FormContainer").hide();
                                        $("._EntityLinkContainer").show();
                                    }
                                    else
                                    {
                                        $("._FormContainer").show();
                                        $("._EntityLinkContainer").hide();
                                    }
                                })

                                $(".index").on("click", function ()
                                {
                                    $(".menuson li.active").removeClass("active");
                                    $('.menuson').animate({
                                        'height': 0
                                    }, 300);
                                })


                            });
                        },
                        error: function (e)
                        {
                            debugger
                        }
                    });
                }
                $("#basicForm").click(function ()
                {
                    $("._FormContainer").show();
                    $("._EntityLinkContainer").hide();
                })
            })();
            /*---------------------------------------导航切换 end---------------------------------------------*/

            /*---------------------------------------退出绑定 begin---------------------------------------------*/
            $("a#logout").on("click", function ()
            {
                $.post("/login.aspx", { type: "logout" }, function (temp)
                {
                    alert("退出成功");
                    window.parent.location.href = "/login.aspx";
                });
            });
            /*---------------------------------------退出绑定 end---------------------------------------------*/
        });
    </script>
    <script src="/Service/Data/JsHub.ashx?itemtype=form&entityname=<%=entityName %>&itemname=<%=formName %>"></script>
    <asp:Literal runat="server" ID="FormJS"></asp:Literal>
</body>
</html>
